home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / VIDEO.ASM < prev   
Assembly Source File  |  1992-12-08  |  25KB  |  1,245 lines

  1. ;$Author:   DCODY  $
  2. ;$Date:   08 Dec 1992 17:27:24  $
  3. ;$Header:   X:/sccs/video/video.asv   1.2   08 Dec 1992 17:27:24   DCODY  $
  4. ;$Log:   X:/sccs/video/video.asv  $
  5. ;  
  6. ;     Rev 1.2   08 Dec 1992 17:27:24   DCODY
  7. ;  corrected some large model problems with parameter passing
  8. ;  
  9. ;     Rev 1.1   29 Oct 1992 14:47:52   DCODY
  10. ;  tiny model data declaration is corrected
  11. ;  
  12. ;     Rev 1.0   15 Jun 1992 09:45:32   BCRANE
  13. ;  Initial revision.
  14. ;$Logfile:   X:/sccs/video/video.asv  $
  15. ;$Modtimes$
  16. ;$Revision:   1.2  $
  17. ;$Workfile:   video.asm  $ 
  18.  
  19.     Title    Video.asm  -- Media Vision simple video routines
  20.     page    64,131
  21.  
  22. ;   /*\
  23. ;---|*|
  24. ;---|*|----=====< Video.asm >====-----
  25. ;---|*|
  26. ;---|*| This module provides video bios services for the caller.
  27. ;---|*|
  28. ;   \*/
  29.  
  30.         .xlist
  31.     include model.inc
  32.     include masm.inc
  33.     .list
  34.  
  35. ;
  36. ;   /*\
  37. ;---|*|----====< _ttyout ( char *, char *,...0 ) >====----
  38. ;---|*|
  39. ;---|*|  This routine writes the text strings out via TTY
  40. ;---|*|
  41. ;---|*|  On Entry:
  42. ;---|*|     int1 is the AND mask
  43. ;---|*|     int2 is the XOR mask
  44. ;---|*|     rect * is rectangle to pop
  45. ;---|*|
  46. ;---|*|  On Exit:
  47. ;---|*|     Nothing
  48. ;---|*|
  49. ;---|*|----====< _videoattr (int1, int2, rect * ) >====----
  50. ;---|*|
  51. ;---|*|  This routine will AND/XOR the contents of the rectangle
  52. ;---|*|
  53. ;---|*|  On Entry:
  54. ;---|*|     int1 is the AND mask
  55. ;---|*|     int2 is the XOR mask
  56. ;---|*|     rect * is rectangle to pop
  57. ;---|*|
  58. ;---|*|  On Exit:
  59. ;---|*|     Nothing
  60. ;---|*|
  61. ;---|*|----====< int _videocard () >====----
  62. ;---|*|
  63. ;---|*|  This routine returns the active adapter type
  64. ;---|*|
  65. ;---|*|  On Entry:
  66. ;---|*|     Nothing
  67. ;---|*|
  68. ;---|*|  On Exit:
  69. ;---|*|     ax = 1=hgc/mono,2=cga,4=ega,8=vga, 0=error
  70. ;---|*|
  71. ;---|*|----====< _videofill (int1, int2, rect * ) >====----
  72. ;---|*|
  73. ;---|*|  This routine will FILL the contents of the rectangle
  74. ;---|*|
  75. ;---|*|  On Entry:
  76. ;---|*|     int1 is the character
  77. ;---|*|     int2 is the attribute
  78. ;---|*|     rect * is rectangle to pop
  79. ;---|*|
  80. ;---|*|  On Exit:
  81. ;---|*|     Nothing
  82. ;---|*|
  83. ;---|*|
  84. ;---|*|----=====< long _videogetcurs () >====-----
  85. ;---|*|
  86. ;---|*| This function returns the cursor position
  87. ;---|*|
  88. ;---|*|   On Exit:
  89. ;---|*|
  90. ;---|*|     DX holds the column position
  91. ;---|*|     AX holds the row    position
  92. ;---|*|
  93. ;---|*|
  94. ;---|*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  95. ;---|*|
  96. ;---|*| This function sets the cursor position
  97. ;---|*|
  98. ;---|*|   On Entry:
  99. ;---|*|
  100. ;---|*|     int1 is the row
  101. ;---|*|     int2 is the column
  102. ;---|*|
  103. ;---|*|
  104. ;---|*|----=====< void _videopage ( int1 ) >====-----
  105. ;---|*|
  106. ;---|*| This function sets the current video page
  107. ;---|*|
  108. ;---|*|   On Entry:
  109. ;---|*|
  110. ;---|*|     int1 is the page #
  111. ;---|*|
  112. ;---|*|
  113. ;---|*|----=====< void _videocshape  ( int1, int2 ) >====-----
  114. ;---|*|
  115. ;---|*| This function sets the cursor shape
  116. ;---|*|
  117. ;---|*|   On Entry:
  118. ;---|*|
  119. ;---|*|     int1 is the starting cursor scan line
  120. ;---|*|     int2 is the ending   cursor scan line
  121. ;---|*|
  122. ;---|*|
  123. ;---|*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  124. ;---|*|
  125. ;---|*| This module provides any video bios services for the caller.
  126. ;---|*|
  127. ;---|*|   On Entry:
  128. ;---|*|
  129. ;---|*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  130. ;---|*|
  131. ;---|*|   On Exit:
  132. ;---|*|
  133. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  134. ;---|*|
  135. ;---|*|----=====< void _zipout ( char * ) >====-----
  136. ;---|*|
  137. ;---|*| This routine writes an ASCIIZ string to the screen at the
  138. ;---|*| current cursor position.
  139. ;---|*|
  140. ;---|*|   On Entry:
  141. ;---|*|
  142. ;---|*|     char * is a pointer to the string
  143. ;---|*|
  144. ;---|*|   On Exit:
  145. ;---|*|
  146. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  147. ;---|*|
  148. ;   \*/
  149.  
  150. if MODELSIZE eq 0
  151.     .code
  152. else
  153.     .data
  154. endif
  155.  
  156. rect    struc
  157.  xmin    dw    0
  158.  ymin    dw    0
  159.  xmax    dw    0
  160.  ymax    dw    0
  161. rect    ends
  162.  
  163. video    struc
  164.  wndr    dw    4 dup (0)    ; screen X,Y
  165.  row    dw    0        ; current cursor row
  166.  col    dw    0        ; current cursor column
  167.  attr    db    0        ; attribute
  168.  wrap    db    0        ; wrap flag
  169.  soff    dw    0        ; current screen offset
  170.  sseg    dw    0        ; current screen segment
  171. video    ends
  172.  
  173. VideoPage    db     0    ; save a copy for speed!
  174. OrigCursShape    dw    -1    ; cursor shape
  175.  
  176. if @datasize
  177.     Extrn    CurWnd:dword    ; pointer to window block
  178. else
  179.     Extrn    CurWnd:word    ; pointer to window block
  180. endif
  181.  
  182. BLACK_bk    equ    000h
  183. BLUE_bk     equ    010h
  184. GREEN_bk    equ    020h
  185. CYAN_bk     equ    030h
  186. RED_bk        equ    040h
  187. PURPLE_bk    equ    050h
  188. BROWN_bk    equ    060h
  189. GREY_bk     equ    070h
  190.  
  191. BLACK_fg    equ    000h
  192. BLUE_fg     equ    001h
  193. GREEN_fg    equ    002h
  194. CYAN_fg     equ    003h
  195. RED_fg        equ    004h
  196. PURPLE_fg    equ    005h
  197. BROWN_fg    equ    006h
  198. GREY_fg     equ    007h
  199. IBLACK_fg    equ    008h
  200. IBLUE_fg    equ    009h
  201. IGREEN_fg    equ    00Ah
  202. ICYAN_fg    equ    00Bh
  203. IRED_fg     equ    00Ch
  204. IPURPLE_fg    equ    00Dh
  205. IBROWN_fg    equ    00Eh
  206. WHITE_fg    equ    00Fh
  207.  
  208. attributetable    label    byte
  209.     db    GREY_fg     ;  0    CYAN_bk +
  210.     db    IGREEN_fg    ;  1    CYAN_bk +
  211.     db    GREY_fg     ;  2    CYAN_bk +
  212.     db    GREY_fg     ;  3    CYAN_bk +
  213.     db    GREY_fg     ;  4    CYAN_bk +
  214.     db    GREY_fg     ;  5    CYAN_bk +
  215.     db    GREY_fg     ;  6    CYAN_bk +
  216.     db    IGREEN_fg    ;  7    CYAN_bk +
  217.     db    GREY_fg     ;  8    CYAN_bk +
  218.     db    GREY_fg     ;  9    CYAN_bk +
  219.     db    GREY_fg     ;  a    CYAN_bk +
  220.     db    GREY_fg     ;  b    CYAN_bk +
  221.     db    GREY_fg     ;  c    CYAN_bk +
  222.     db    GREY_fg     ;  d    CYAN_bk +
  223.     db    GREY_fg     ;  e    CYAN_bk +
  224.     db    GREY_fg     ;  f    CYAN_bk +
  225.  
  226.     db    IGREEN_fg    ; 10    CYAN_bk +
  227.     db    IGREEN_fg    ; 11    CYAN_bk +
  228.     db    GREY_fg     ; 12    CYAN_bk +
  229.     db    GREY_fg     ; 13    CYAN_bk +
  230.     db    GREY_fg     ; 14    CYAN_bk +
  231.     db    GREY_fg     ; 15    CYAN_bk +
  232.     db    GREY_fg     ; 16    CYAN_bk +
  233.     db    GREY_fg     ; 17    CYAN_bk +
  234.     db    GREY_fg     ; 18    CYAN_bk +
  235.     db    GREY_fg     ; 19    CYAN_bk +
  236.     db    0        ; 1a    0
  237.     db    0        ; 1b    0
  238.     db    GREY_fg     ; 1c    CYAN_bk +
  239.     db    GREY_fg     ; 1d    CYAN_bk +
  240.     db    GREY_fg     ; 1e    CYAN_bk +
  241.     db    GREY_fg     ; 1f    CYAN_bk +
  242.  
  243.     db    0        ; 20
  244.     db    BLACK_fg    ; 21    CYAN_bk +
  245.     db    BLACK_fg    ; 22    CYAN_bk +
  246.     db    BLACK_fg    ; 23    CYAN_bk +
  247.     db    BLACK_fg    ; 24    CYAN_bk +
  248.     db    BLACK_fg    ; 25    CYAN_bk +
  249.     db    BLACK_fg    ; 26    CYAN_bk +
  250.     db    BLACK_fg    ; 27    CYAN_bk +
  251.     db    BLACK_fg    ; 28    CYAN_bk +
  252.     db    BLACK_fg    ; 29    CYAN_bk +
  253.     db    BLACK_fg    ; 2a    CYAN_bk +
  254.     db    BLACK_fg    ; 2b    CYAN_bk +
  255.     db    BLACK_fg    ; 2c    CYAN_bk +
  256.     db    BLACK_fg    ; 2d    CYAN_bk +
  257.     db    BLACK_fg    ; 2e    CYAN_bk +
  258.     db    BLACK_fg    ; 2f    CYAN_bk +
  259.  
  260.     db    BLACK_fg    ; 30    CYAN_bk +
  261.     db    BLACK_fg    ; 31    CYAN_bk +
  262.     db    BLACK_fg    ; 32    CYAN_bk +
  263.     db    BLACK_fg    ; 33    CYAN_bk +
  264.     db    BLACK_fg    ; 34    CYAN_bk +
  265.     db    BLACK_fg    ; 35    CYAN_bk +
  266.     db    BLACK_fg    ; 36    CYAN_bk +
  267.     db    BLACK_fg    ; 37    CYAN_bk +
  268.     db    BLACK_fg    ; 38    CYAN_bk +
  269.     db    BLACK_fg    ; 39    CYAN_bk +
  270.     db    BLACK_fg    ; 3a    CYAN_bk +
  271.     db    BLACK_fg    ; 3b    CYAN_bk +
  272.     db    BLACK_fg    ; 3c    CYAN_bk +
  273.     db    BLACK_fg    ; 3d    CYAN_bk +
  274.     db    BLACK_fg    ; 3e    CYAN_bk +
  275.     db    BLACK_fg    ; 3f    CYAN_bk +
  276.  
  277.     db    BLACK_fg    ; 40    CYAN_bk +
  278.     db    BLACK_fg    ; 41    CYAN_bk +
  279.     db    BLACK_fg    ; 42    CYAN_bk +
  280.     db    BLACK_fg    ; 43    CYAN_bk +
  281.     db    BLACK_fg    ; 44    CYAN_bk +
  282.     db    BLACK_fg    ; 45    CYAN_bk +
  283.     db    BLACK_fg    ; 46    CYAN_bk +
  284.     db    BLACK_fg    ; 47    CYAN_bk +
  285.     db    BLACK_fg    ; 48    CYAN_bk +
  286.     db    BLACK_fg    ; 49    CYAN_bk +
  287.     db    BLACK_fg    ; 4a    CYAN_bk +
  288.     db    BLACK_fg    ; 4b    CYAN_bk +
  289.     db    BLACK_fg    ; 4c    CYAN_bk +
  290.     db    BLACK_fg    ; 4d    CYAN_bk +
  291.     db    BLACK_fg    ; 4e    CYAN_bk +
  292.     db    BLACK_fg    ; 4f    CYAN_bk +
  293.  
  294.     db    BLACK_fg    ; 50    CYAN_bk +
  295.     db    BLACK_fg    ; 51    CYAN_bk +
  296.     db    BLACK_fg    ; 52    CYAN_bk +
  297.     db    BLACK_fg    ; 53    CYAN_bk +
  298.     db    BLACK_fg    ; 54    CYAN_bk +
  299.     db    BLACK_fg    ; 55    CYAN_bk +
  300.     db    BLACK_fg    ; 56    CYAN_bk +
  301.     db    BLACK_fg    ; 57    CYAN_bk +
  302.     db    BLACK_fg    ; 58    CYAN_bk +
  303.     db    BLACK_fg    ; 59    CYAN_bk +
  304.     db    BLACK_fg    ; 5a    CYAN_bk +
  305.     db    BLACK_fg    ; 5b    CYAN_bk +
  306.     db    BLACK_fg    ; 5c    CYAN_bk +
  307.     db    BLACK_fg    ; 5d    CYAN_bk +
  308.     db    BLACK_fg    ; 5e    CYAN_bk +
  309.     db    BLACK_fg    ; 5f    CYAN_bk +
  310.  
  311.     db    BLACK_fg    ; 60    CYAN_bk +
  312.     db    BLACK_fg    ; 61    CYAN_bk +
  313.     db    BLACK_fg    ; 62    CYAN_bk +
  314.     db    BLACK_fg    ; 63    CYAN_bk +
  315.     db    BLACK_fg    ; 64    CYAN_bk +
  316.     db    BLACK_fg    ; 65    CYAN_bk +
  317.     db    BLACK_fg    ; 66    CYAN_bk +
  318.     db    BLACK_fg    ; 67    CYAN_bk +
  319.     db    BLACK_fg    ; 68    CYAN_bk +
  320.     db    BLACK_fg    ; 69    CYAN_bk +
  321.     db    BLACK_fg    ; 6a    CYAN_bk +
  322.     db    BLACK_fg    ; 6b    CYAN_bk +
  323.     db    BLACK_fg    ; 6c    CYAN_bk +
  324.     db    BLACK_fg    ; 6d    CYAN_bk +
  325.     db    BLACK_fg    ; 6e    CYAN_bk +
  326.     db    BLACK_fg    ; 6f    CYAN_bk +
  327.  
  328.     db    BLACK_fg    ; 70    CYAN_bk +
  329.     db    BLACK_fg    ; 71    CYAN_bk +
  330.     db    BLACK_fg    ; 72    CYAN_bk +
  331.     db    BLACK_fg    ; 73    CYAN_bk +
  332.     db    BLACK_fg    ; 74    CYAN_bk +
  333.     db    BLACK_fg    ; 75    CYAN_bk +
  334.     db    BLACK_fg    ; 76    CYAN_bk +
  335.     db    BLACK_fg    ; 77    CYAN_bk +
  336.     db    BLACK_fg    ; 78    CYAN_bk +
  337.     db    BLACK_fg    ; 79    CYAN_bk +
  338.     db    BLACK_fg    ; 7a    CYAN_bk +
  339.     db    BLACK_fg    ; 7b    CYAN_bk +
  340.     db    BLACK_fg    ; 7c    CYAN_bk +
  341.     db    BLACK_fg    ; 7d    CYAN_bk +
  342.     db    BLACK_fg    ; 7e    CYAN_bk +
  343.     db    BLACK_fg    ; 7f    CYAN_bk +
  344.  
  345.         .code
  346.  
  347. ;
  348. ;   /*\
  349. ;---|*|----====< BackupVideo ( rect *, char far *, int, int ) >====----
  350. ;---|*|
  351. ;---|*| Back up a rectangle in the current window
  352. ;---|*|
  353. ;---|*| void BackupVideo (rect *r, char far *b, int morex, int morey);
  354. ;---|*| Save the screen contents of rectangle X, plus some...
  355. ;---|*|
  356. ;---|*| Entry Conditions.
  357. ;---|*|     parm1 is a pointer to the rectangle
  358. ;---|*|     parm2 is a far pointer to the target buffer
  359. ;---|*|     parm3 is an int requesting x more rows to be save
  360. ;---|*|     parm4 is an int requesting x more colums to be save
  361. ;---|*|
  362. ;---|*| Exit Conditions:
  363. ;---|*|     nothing
  364. ;---|*|
  365. ;   \*/
  366.     public    BackupVideo
  367. BackupVideo    proc    near
  368.     push    bp
  369.     mov    bp,sp
  370.     push    si
  371.     push    di
  372.     push    ds
  373.     push    es
  374. ;
  375. ; calculate the screen area
  376. ;
  377.     call    calcarea
  378. ;
  379. a00:
  380.     push    cx
  381.     mov    cx,bx
  382.     rep    movsw
  383.     add    si,dx
  384.     pop    cx
  385.     loop    a00
  386.  
  387.     pop    es
  388.     pop    ds
  389.     pop    di
  390.     pop    si
  391.     pop    bp
  392.         ret
  393.  
  394. BackupVideo    endp
  395.  
  396. ;
  397. ;   /*\
  398. ;---|*|----====< calcarea >====----
  399. ;---|*|
  400. ;---|*| calculate the area to be moved
  401. ;---|*| the stack frame is pointed to by bp, as it entered into
  402. ;---|*| the caller's routine.
  403. ;---|*|
  404. ;---|*| Entry Conditions.
  405. ;---|*|     BP points to:
  406. ;---|*|       parm1 is a pointer to the rectangle
  407. ;---|*|       parm2 is a far pointer to the target buffer
  408. ;---|*|       parm3 is an int requesting xxx more rows to be save
  409. ;---|*|       parm4 is an int requesting xxx more colums to be save
  410. ;---|*|
  411. ;---|*| Exit Conditions:
  412. ;---|*|     ES:DI point to the char far * buffer
  413. ;---|*|     DS:SI point to the video screen
  414. ;---|*|     CX holds the # of rows to move
  415. ;---|*|     BX holds the # of columns to save (word count)
  416. ;---|*|     DX holds the # of columns to skip (byte count)
  417. ;---|*|     direction flag is set
  418. ;---|*|
  419. ;   \*/
  420.  
  421. if @datasize    ;; if large model, adjust for far pointers
  422.  
  423. parm1    equ    <wParm1>    ; word
  424. parm2    equ    <wParm2>    ; dword
  425. parm3    equ    <wParm4>    ; word
  426. parm4    equ    <wParm5>    ; word
  427.  
  428. else
  429.  
  430. parm1    equ    <wParm1>    ; dword
  431. parm2    equ    <wParm3>    ; dword
  432. parm3    equ    <wParm4+2>    ; word
  433. parm4    equ    <wParm4+4>    ; word
  434.  
  435. endif
  436.  
  437. calcarea        proc    near
  438.  
  439. ;
  440. ; get the pointer to the rectangle structure
  441. ;
  442. if @datasize
  443.     push    ds            ; to be popped later
  444.         lds     si,[parm1]              ; large model...
  445. else
  446.     mov    si,[parm1]        ; small model...
  447. endif
  448.  
  449. ;
  450. ; get the number of rows to be saved into cx
  451. ;
  452.     mov    cx,[si.xmax]        ; calculate the # of rows
  453.     mov    ax,[si.xmin]
  454.     sub    cx,ax
  455.     inc    cx
  456.  
  457.     mov    ah,80*2         ; ax holds the offset to the
  458.     mul    ah            ; start of the video buffer
  459.  
  460.     add    cx,[parm3]        ; add in any more lines
  461. ;
  462. ; get the number of columns to save in bx, columns to skip in dx
  463. ;
  464.     mov    bx,[si.ymax]        ; calculate the number of colums
  465.     sub    bx,[si.ymin]
  466.     add    ax,[si.ymin]
  467.         add     ax,[si.ymin]
  468.     inc    bx
  469.  
  470.     add    bx,[parm4]        ; add in any more columns
  471.  
  472.     mov    dx,80            ; calc the # of columns to skip
  473.     sub    dx,bx            ; bx holds the # of ints to move
  474.     shl    dx,1            ; dx holds the # of characters to skip
  475. ;
  476. ; load the screen segment:offset into ds:si
  477. ;
  478. if @datasize
  479.     pop    ds            ; restore ds temporarily
  480.         les     di,CurWnd               ; get the segment of the window pointer
  481.     mov    ds,es:[di.sseg]
  482. else
  483.     mov    di,CurWnd        ; get the segment of the window pointer
  484.     mov    ds,[di.sseg]
  485. endif
  486.         mov     si,ax                   ; si points to the start
  487. ;
  488. ; get the buffer pointer into es:di
  489. ;
  490.     les    di,[parm2]        ; get the buffer pointer
  491.  
  492.     cld                ; make sure we move forward
  493.     ret
  494.  
  495. calcarea    endp
  496.  
  497. ;
  498. ;   /*\
  499. ;---|*|----====< ChangeAttributes ( int, int, int, int ) >====----
  500. ;---|*|
  501. ;---|*| Change some attributes in the rectangle
  502. ;---|*|
  503. ;   \*/
  504.     public    ChangeAttributes
  505. ChangeAttributes proc
  506.     push    bp
  507.     mov    bp,sp
  508.     push    es
  509.     push    di
  510.  
  511. if @datasize
  512.     les    di,[CurWnd]
  513.     mov    es,es:[di.sseg]
  514. else
  515.     mov    di,[CurWnd]
  516.     mov    es,[di.sseg]
  517. endif
  518. ;
  519. chat00:
  520.     mov    cx,wParm4        ; get the ending column
  521.     mov    bx,wParm2        ; get the starting column
  522.     sub    cx,bx            ; cx holds the length
  523.     jb    chat20            ; skip if inverted
  524.  
  525.     inc    cx            ; include the starting columm
  526.  
  527.     mov    di,wParm1        ; get the row #
  528.     cmp    di,wParm3        ; skip out if past the end
  529.     ja    chatdone        ; exit now
  530.  
  531.     mov    ax,80*2
  532.     mul    di
  533.     xchg    ax,di
  534.     add    di,bx
  535.     add    di,bx            ; di points to the end
  536.  
  537.     lea    bx,attributetable    ; get the attribute xlate table
  538.     ;
  539.     chat05:
  540.         mov     al,es:[di]
  541.     test    al,80h
  542.     jnz    chat07
  543.     xlat
  544.     or    al,al
  545.     jz    chat10
  546.     and    bptr es:[di+1],070h
  547.     or    es:[di+1],al
  548.     jmp    short chat10
  549.     ;
  550.     chat07:
  551.     and    bptr es:[di+1],77h
  552.     or    bptr es:[di+1],0Fh
  553.     ;
  554.     chat10:
  555.     inc    di
  556.         inc     di
  557.     loop    chat05            ; go for more
  558. ;
  559. chat20:
  560.     inc    wptr wParm1        ; move down the screen
  561.     jmp    short chat00
  562. ;
  563. chatdone:
  564.     pop    di
  565.     pop    es
  566.     pop    bp
  567.     ret
  568.  
  569. ChangeAttributes endp
  570.  
  571. ;
  572. ;   /*\
  573. ;---|*|----====< RestoreVideo ( rect *, char far *, int, int ) >====----
  574. ;---|*|
  575. ;---|*| void RestoreVideo (rect *r, char far *b, int morex, int morey);
  576. ;---|*|
  577. ;---|*| restore the screen contents of rectangle X, plus some...
  578. ;---|*|
  579. ;---|*| Entry Conditions.
  580. ;---|*|     parm1 is a pointer to the rectangle
  581. ;---|*|     parm2 is a far pointer to the source buffer
  582. ;---|*|     parm3 is an int requesting x more rows to be save
  583. ;---|*|     parm4 is an int requesting x more colums to be save
  584. ;---|*|
  585. ;---|*| Exit Conditions:
  586. ;---|*|     nothing
  587. ;---|*|
  588. ;   \*/
  589.     public    RestoreVideo
  590. RestoreVideo    proc    near
  591.         push    bp
  592.     mov    bp,sp
  593.     push    si
  594.     push    di
  595.     push    ds
  596.     push    es
  597. ;
  598. ; calculate the screen area
  599. ;
  600.     call    calcarea
  601. ;
  602. ; swap the pointers
  603. ;
  604.     push    es
  605.     push    ds
  606.     pop    es
  607.     pop    ds
  608.     xchg    si,di
  609. ;
  610. vr00:
  611. ;
  612. ; move the data back into the video buffer
  613. ;
  614.         push    cx
  615.     mov    cx,bx
  616.     rep    movsw
  617.     add    di,dx
  618.     pop    cx
  619.     loop    vr00
  620. ;
  621. ; all done, return home
  622. ;
  623.     pop    es
  624.     pop    ds
  625.     pop    di
  626.     pop    si
  627.     pop    bp
  628.         ret
  629.  
  630. RestoreVideo    endp
  631.  
  632. ;
  633. ;   /*\
  634. ;---|*|----====< _ttyout ( char *, char *,...0 );
  635. ;---|*|
  636. ;---|*|  This routine writes the text strings out via TTY
  637. ;---|*|
  638. ;---|*|  On Entry:
  639. ;---|*|     int1 is the AND mask
  640. ;---|*|     int2 is the XOR mask
  641. ;---|*|     rect * is rectangle to pop
  642. ;---|*|
  643. ;---|*|  On Exit:
  644. ;---|*|     Nothing
  645. ;---|*|
  646. ;   \*/
  647.     public    _ttyout
  648. _ttyout proc
  649.     push    bp
  650.     mov    bp,sp
  651.     push    ds
  652.     push    si
  653.  
  654.     lea    bp,wParm1        ; bp points to the next string
  655.     mov    bh,VideoPage        ; get the current page
  656.     cld
  657. ;
  658. to_05:
  659. if @datasize
  660.     lds    si,[bp]         ; get the next string
  661.     add    bp,4
  662.     mov    ax,ds
  663.     or    ax,si
  664. else
  665.     mov    si,[bp]         ; get the next string
  666.     add    bp,2
  667.     or    si,si
  668. endif
  669.     jz    to_exit         ; all done, exit home
  670.     mov    ah,0eh
  671. ;
  672. to_10:
  673.     lodsb                ; get the character
  674.     or    al,al
  675.     jz    to_05            ; go get the next string
  676.     int    10h
  677.     jmp    short to_10
  678. ;
  679. to_exit:
  680.     pop    si
  681.     pop    ds
  682.     pop    bp
  683.     ret
  684.  
  685. _ttyout endp
  686.  
  687. ;
  688. ;   /*\
  689. ;---|*|----====< _videoattr (int1, int2, rect * );
  690. ;---|*|
  691. ;---|*|  This routine will AND/XOR the contents of the rectangle
  692. ;---|*|
  693. ;---|*|  On Entry:
  694. ;---|*|     int1 is the AND mask
  695. ;---|*|     int2 is the XOR mask
  696. ;---|*|     rect * is rectangle to pop
  697. ;---|*|
  698. ;---|*|  On Exit:
  699. ;---|*|     Nothing
  700. ;   \*/
  701.  
  702.     public    _videoattr
  703. _videoattr      proc
  704.     push    bp
  705.     mov    bp,sp
  706.     push    ds
  707.         push    es
  708.     push    di
  709.     push    si
  710.  
  711. @psh    equ    (4*2)+2         ; 4 more words stored
  712.  
  713. lRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  714. lCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  715. lPtr        equ    wptr [bp-@psh-4] ; starting address
  716. lNext        equ    wptr [bp-@psh-6] ; offset to next address
  717.     sub    sp,8            ; save some more space
  718.  
  719. if @datasize
  720.     lds    si,wParm3        ; get the rectangle pointer
  721. else
  722.     mov    si,wParm3        ; get the rectangle pointer
  723. endif
  724.  
  725.         mov     ax,[si.xmin]
  726.     mov    dx,[si.xmax]
  727.     sub    dx,ax
  728.     inc    dx            ; bx has max rows
  729.     mov    lRows,dx
  730.  
  731.     mov    bl,80*2
  732.     mul    bl
  733.  
  734.     mov    cx,[si.ymin]
  735.     add    ax,cx
  736.     add    ax,cx            ; ax holds offset to video
  737.     mov    bx,[si.ymax]
  738.     sub    bx,cx
  739.     inc    bx            ; bx has max rows
  740.  
  741.     mov    lCols,bx
  742.  
  743.     cmp    dx,0            ; no rows, bomb out...
  744.     jbe    ViAt_exit
  745.     cmp    bx,0            ; no colums, bomb out...
  746.     jbe    ViAt_exit
  747.  
  748.     sub    bx,80            ; get next ptr count
  749.         neg     bx
  750.     add    bx,bx            ; double
  751.  
  752.     mov    lNext,bx
  753.  
  754. if @datasize
  755.     les    di,[CurWnd]
  756.     mov    es,es:[di.sseg]
  757. else
  758.     mov    di,[CurWnd]
  759.     mov    es,[di.sseg]
  760. endif
  761.  
  762.     mov    di,ax
  763.     inc    di            ; point to attributes
  764.  
  765.     mov    al,bptr wParm1        ; AND mask
  766.     mov    ah,wParm2        ; XOR mask
  767. ;
  768. ViAt_05:
  769.     mov    cx,lCols        ; refresh the column count
  770. ;
  771. ViAt_10:
  772.     and    es:[di],al
  773.     xor    es:[di],ah
  774.     add    di,2
  775.     loop    ViAt_10
  776.     add    di,lNext
  777.     dec    lRows
  778.     jnz    ViAt_05
  779. ;
  780. ; all done, exit home...
  781. ;
  782. ViAt_exit:
  783.     add    sp,8            ; toss out the local storage
  784.         pop     si
  785.         pop     di
  786.     pop    es
  787.     pop    ds
  788.     pop    bp
  789.     ret
  790.  
  791. _videoattr    endp
  792.  
  793. ;
  794. ;   /*\
  795. ;---|*|----====< int _videocard () >====----
  796. ;---|*|
  797. ;---|*|  This routine returns the active adapter type
  798. ;---|*|
  799. ;---|*|  On Entry:
  800. ;---|*|     Nothing
  801. ;---|*|
  802. ;---|*|  On Exit:
  803. ;---|*|     ax = 1=hgc/mono,2=cga,3=ega,4=vga
  804. ;   \*/
  805.     public    _videocard
  806. _videocard    proc            ; was a near here kdn
  807.     mov    ah,0fh            ; check for MONO card being active now
  808.     int    10h
  809.     cmp    al,07h            ; current mono mode?
  810.     mov    ax,1            ; (set just in case)
  811.     jz    vc_exit         ; yes, return it...
  812.  
  813.     mov    ax,1c00h
  814.     mov    cx,7
  815.     int    10h
  816.     cmp    al,1ch            ; VGA?
  817.     mov    al,08            ; (setup just in case)
  818.     jz    vc_exit         ; yes, exit now.
  819.  
  820.     mov    ah,12h            ; check EGA
  821.     mov    bl,10h
  822.     int    10h
  823.     cmp    bl,10h            ; changed? (EGA card?)
  824.     mov    al,04
  825.     jnz    vc_exit         ; yes, exit now
  826.  
  827.     mov    al,02            ; return CGA
  828. ;
  829. vc_exit:
  830.     cbw
  831.     ret
  832.  
  833. _videocard     endp
  834.  
  835. ;
  836. ;   /*\
  837. ;---|*|----====< _videofill (int1, int2, rect * );
  838. ;---|*|
  839. ;---|*|  This routine will fill the contents of the rectangle
  840. ;---|*|
  841. ;---|*|  On Entry:
  842. ;---|*|     int1 is the CHARACTER
  843. ;---|*|     int2 is the ATTRIBUTE
  844. ;---|*|     rect * is rectangle to pop
  845. ;---|*|
  846. ;---|*|  On Exit:
  847. ;---|*|     Nothing
  848. ;   \*/
  849.  
  850.     public    _videofill
  851. _videofill      proc
  852.     push    bp
  853.     mov    bp,sp
  854.     push    ds
  855.         push    es
  856.     push    di
  857.     push    si
  858.  
  859. @psh    equ    (4*2)+2         ; 4 registers stored
  860.  
  861. vfRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  862. vfCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  863. vfPtr        equ    wptr [bp-@psh-4] ; starting address
  864. vfNext        equ    wptr [bp-@psh-6] ; offset to next address
  865.         sub     sp,8                    ; save some more space
  866.  
  867. if @datasize
  868.     lds    si,wParm3        ; get the rectangle pointer
  869. else
  870.     mov    si,wParm3        ; get the rectangle pointer
  871. endif
  872.  
  873.         mov     ax,[si.xmin]
  874.     mov    dx,[si.xmax]
  875.     sub    dx,ax
  876.     inc    dx            ; bx has max rows
  877.     mov    vfRows,dx
  878.  
  879.     mov    bl,80*2
  880.     mul    bl
  881.  
  882.     mov    cx,[si.ymin]
  883.     add    ax,cx
  884.     add    ax,cx            ; ax holds offset to video
  885.     mov    bx,[si.ymax]
  886.     sub    bx,cx
  887.     inc    bx            ; bx has max rows
  888.  
  889.     mov    vfCols,bx
  890.  
  891.     cmp    dx,0            ; no rows, bomb out...
  892.     jbe    ViFi_exit
  893.     cmp    bx,0            ; no colums, bomb out...
  894.     jbe    ViFi_exit
  895.  
  896.     sub    bx,80            ; get next ptr count
  897.     neg    bx
  898.     add    bx,bx            ; double
  899.  
  900.     mov    vfNext,bx
  901.  
  902.  
  903. if @datasize
  904.     les    di,dptr [CurWnd]
  905.     mov    es,es:[di.sseg]
  906. else
  907.     mov    di,[CurWnd]
  908.     mov    es,[di.sseg]
  909. endif
  910.     mov    di,ax
  911.  
  912.     mov    al,wParm1        ; character
  913.     mov    ah,wParm2        ; attribute
  914.     cld
  915. ;
  916. ViFi_05:
  917.     mov    cx,vfCols        ; refresh the column count
  918.     rep    stosw
  919.     add    di,vfNext
  920.     dec    vfRows
  921.     jnz    ViFi_05
  922. ;
  923. ViFi_exit:
  924. ;
  925. ; all done, exit home...
  926. ;
  927.     add    sp,8            ; toss out the local storage
  928.         pop     si
  929.         pop     di
  930.     pop    es
  931.     pop    ds
  932.     pop    bp
  933.     ret
  934.  
  935. _videofill    endp
  936.  
  937. ;
  938. ;   /*\
  939. ;---|*|
  940. ;---|*|----=====< long _videogetcurs () >====-----
  941. ;---|*|
  942. ;---|*| This function returns the cursor position
  943. ;---|*|
  944. ;---|*|   On Exit:
  945. ;---|*|
  946. ;---|*|     DX holds the column position
  947. ;---|*|     AX holds the row    position
  948. ;---|*|
  949. ;---|*|
  950. ;   \*/
  951.     public    _videogetcurs
  952. _videogetcurs    proc
  953.     push    bp
  954.     mov    bp,sp
  955.  
  956.     mov    ah,03h
  957.     mov    bh,VideoPage
  958.     int    10h
  959.  
  960.     sub    ax,ax
  961.     xchg    al,dh
  962.  
  963.     pop    bp
  964.     ret
  965.  
  966. _videogetcurs    endp
  967.  
  968. ;
  969. ;   /*\
  970. ;---|*|
  971. ;---|*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  972. ;---|*|
  973. ;---|*| This function sets the cursor position
  974. ;---|*|
  975. ;---|*|   On Entry:
  976. ;---|*|
  977. ;---|*|     int1 is the row
  978. ;---|*|     int2 is the column
  979. ;---|*|
  980. ;   \*/
  981.     public    _videosetcurs
  982. _videosetcurs    proc
  983.     push    bp
  984.     mov    bp,sp
  985.  
  986.     mov    ah,02h
  987.         mov     bh,VideoPage
  988.     mov    dl,byte ptr wParm2
  989.     mov    dh,byte ptr wParm1
  990.     int    10h
  991.  
  992.     pop    bp
  993.     ret
  994.  
  995. _videosetcurs    endp
  996.  
  997. ;
  998. ;   /*\
  999. ;---|*|
  1000. ;---|*|----=====< void _videopage ( int1 ) >====-----
  1001. ;---|*|
  1002. ;---|*| This function sets the current video page
  1003. ;---|*|
  1004. ;---|*|   On Entry:
  1005. ;---|*|
  1006. ;---|*|     int1 is the page #
  1007. ;---|*|
  1008. ;---|*|
  1009. ;   \*/
  1010.  
  1011.     public    _videopage
  1012. _videopage      proc
  1013.     push    bp
  1014.     mov    bp,sp
  1015.  
  1016.     mov    ah,05h
  1017.     mov    al,byte ptr wParm1
  1018.     mov    VideoPage,al
  1019.         int     10h
  1020.  
  1021.     pop    bp
  1022.     ret
  1023.  
  1024. _videopage      endp
  1025.  
  1026. ;
  1027. ;   /*\
  1028. ;---|*|
  1029. ;---|*|----=====< void _videocshape  ( int1, int2 ) >====-----
  1030. ;---|*|
  1031. ;---|*| This function sets the cursor shape
  1032. ;---|*|
  1033. ;---|*|   On Entry:
  1034. ;---|*|
  1035. ;---|*|     int1 is the starting cursor scan line
  1036. ;---|*|     int2 is the ending   cursor scan line
  1037. ;---|*|
  1038. ;   \*/
  1039.  
  1040.     public    _videocshape
  1041. _videocshape    proc
  1042.     push    bp
  1043.     mov    bp,sp
  1044.  
  1045.     cmp    OrigCursShape,-1    ; is it -1?
  1046.     jnz    vish_found        ; no, already fetched...
  1047.     mov    ah,3            ; yes, get the original shape
  1048.     int    10h
  1049.     mov    OrigCursShape,cx    ; save the new shape
  1050. ;
  1051. vish_found:
  1052.     mov    cl,byte ptr wParm1    ; get the new shape
  1053.     mov    ch,byte ptr wParm2
  1054.     cmp    cx,-1            ; restoration request?
  1055.     jnz    vish_new
  1056.     mov    cx,OrigCursShape    ; yes, use it!
  1057.     cmp    cx,-1            ; oops it was never set
  1058.     jz    vish_done
  1059. ;
  1060. vish_new:
  1061.     mov    ah,01h
  1062.         int     10h
  1063. ;
  1064. vish_done:
  1065.     pop    bp
  1066.     ret
  1067.  
  1068. _videocshape    endp
  1069.  
  1070. ;
  1071. ;   /*\
  1072. ;---|*|
  1073. ;---|*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  1074. ;---|*|
  1075. ;---|*| This module provides any video bios services for the caller.
  1076. ;---|*|
  1077. ;---|*|   On Entry:
  1078. ;---|*|
  1079. ;---|*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  1080. ;---|*|
  1081. ;---|*|   On Exit:
  1082. ;---|*|
  1083. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  1084. ;---|*|
  1085. ;   \*/
  1086. ;
  1087.  
  1088.     public    _videoint
  1089. _videoint       proc
  1090.     push    bp
  1091.     mov    bp,sp
  1092. if @datasize
  1093.     push    es
  1094. endif
  1095.         push    si
  1096.  
  1097. if @datasize
  1098.     les    si,dParm1
  1099.     mov    ax,es:[si]
  1100. else
  1101.     mov    si,wParm1
  1102.     mov    ax,[si]
  1103. endif
  1104.  
  1105. if @datasize
  1106.     les    si,dParm2
  1107.     mov    bx,es:[si]
  1108. else
  1109.     mov    si,wParm2
  1110.     mov    bx,[si]
  1111. endif
  1112.  
  1113. if @datasize
  1114.     les    si,dParm3
  1115.     mov    cx,es:[si]
  1116. else
  1117.     mov    si,wParm3
  1118.     mov    cx,[si]
  1119. endif
  1120.  
  1121. if @datasize
  1122.     les    si,dParm4
  1123.     mov    dx,es:[si]
  1124. else
  1125.     mov    si,wParm4
  1126.     mov    dx,[si]
  1127. endif
  1128.  
  1129.         int     10h
  1130.  
  1131. if @datasize
  1132.     mov    es:[si],dx
  1133. else
  1134.     mov    [si],dx
  1135. endif
  1136. if @datasize
  1137.     les    si,dParm3
  1138.     mov    es:[si],cx
  1139. else
  1140.     mov    si,wParm3
  1141.     mov    [si],cx
  1142. endif
  1143.  
  1144. if @datasize
  1145.     les    si,dParm2
  1146.     mov    es:[si],bx
  1147. else
  1148.     mov    si,wParm2
  1149.     mov    [si],bx
  1150. endif
  1151.  
  1152. if @datasize
  1153.     les    si,dParm1
  1154.     mov    es:[si],ax
  1155. else
  1156.     mov    si,wParm1
  1157.     mov    [si],ax
  1158. endif
  1159.  
  1160.     pop    si
  1161. if @datasize
  1162.         pop     es
  1163. endif
  1164.         pop     bp
  1165.     ret
  1166.  
  1167. _videoint    endp
  1168.  
  1169. ;
  1170. ;   /*\
  1171. ;---|*|----====< _zipout ( char * ) >====----
  1172. ;---|*|
  1173. ;---|*| print the string at the current cursor position
  1174. ;---|*|
  1175. ;   \*/
  1176.  
  1177.     public    _zipout
  1178. _zipout proc                ;was a near here kdn
  1179.     push    bp
  1180.     mov    bp,sp
  1181.     push    ds
  1182.         push    es
  1183.     push    di
  1184.     push    si
  1185. ;
  1186. ; calculate the starting position
  1187. ;
  1188.     sub    bx,bx
  1189.     mov    es,bx
  1190.         mov     ah,0fh                  ; get the page number
  1191.     int    10h
  1192.     xchg    bh,bl            ; bx holds the cursor index
  1193.  
  1194.     mov    bx,es:[0450h]        ; get the x,y
  1195.  
  1196.     mov    di,0b000h        ; mono segment
  1197.     cmp    al,7
  1198.     jz    @F
  1199.     mov    di,0b800h
  1200.    @@:    mov    es,di
  1201.  
  1202.     mov    al,80*2         ; get the column width
  1203.     mul    bh            ; ax = row offset
  1204.     sub    bh,bh
  1205.     shl    bx,1            ; add colume offset
  1206.     add    ax,bx
  1207.  
  1208.     mov    di,ax            ; es:di point to the screen
  1209. ;
  1210. ; load other registers & rip!
  1211. ;
  1212.  
  1213. if @datasize
  1214.     lds    si,wParm1        ; get the next string
  1215. else
  1216.         mov     si,wParm1               ; get the string address
  1217. endif
  1218.  
  1219.     cld
  1220. ;
  1221. _zi05:
  1222.     lodsb                ; get the next character
  1223.     or    al,al
  1224.     jz    _zi10            ; done...
  1225.     stosb
  1226.     inc    di
  1227.     jmp    short _zi05
  1228. ;
  1229. _zi10:
  1230.     pop    si
  1231.     pop    di
  1232.     pop    es
  1233.     pop    ds
  1234.     pop    bp
  1235.     ret
  1236.  
  1237. _zipout endp
  1238.  
  1239.     end
  1240.  
  1241. ;   /*\
  1242. ;---|*| enf of VIDEO.ASM
  1243. ;   \*/
  1244.  
  1245.